<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2020/6/18
 * Time: 22:57
 */
namespace App\Lib\Sdk;

use App\Lib\Request\Client;
use App\Lib\Sdk\Robot\IRobot;
use App\Lib\Sdk\Spider\Jd2Spider;
use App\Lib\Sdk\Spider\PddSpider;
use App\Lib\Sdk\Spider\TaobaoSpider;
use App\Models\IReadable;


class Manager
{

    const TAOBAO = "taobao";
    const JD = "jd";
    const PDD = "pdd";

    /**
     * @return IRobot
     */
    public static function getSdk()
    {
        $client = new Client();
        $client->server = config("robot.api_server")['uri'];
        $sdk = new IRobot($client);
        return $sdk;
    }


    public static function getSpider($platform)
    {
        $sdk = null;
        $config = null;
        switch ($platform) {
           case self::TAOBAO:
               $config = config("robot.spider.taobao");
               $client = new Client();
               $client->server = $config['api_server'];
               $sdk = new TaobaoSpider($config, $client);
               break;
           case self::JD:
               $config = config("robot.spider.jd");
               $client = new Client();
               $client->server = $config['api_server'];
               $sdk = new Jd2Spider($config, $client);
               break;
           case self::PDD:
               $config = config("robot.spider.pdd");
               $client = new Client();
               $client->server = $config['api_server'];
               $sdk = new PddSpider($config, $client);
               break;

       }
       return $sdk;
    }
}